package com.example.server.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.server.service.FmcFarmBatchService;
import com.example.server.util.RestApiUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class FmcFarmBatchServiceImpl implements FmcFarmBatchService {
    @Override
    public Map updateBatch() {
        return null;
    }

    @Override
    public Map updateFarmBatch(Long farmId) throws Exception {
        RestApiUtil restApiUtil = new RestApiUtil();
        String url = "http://yingzi-fmc-share.test.yingzi.com/api/fmc/v1/breedBatch/" + farmId;
        String resultString = restApiUtil.load(url,"get",null);

        JSONObject jsonObject = JSONObject.parseObject(resultString);
        System.out.println(jsonObject);

        Map map = JSON.parseObject(jsonObject.get("data").toString(),Map.class);
        map.put("traceid",jsonObject.get("traceId").toString());
        System.out.println(map);
        return map;
    }
}
